<?php 
$user=$session->read('User');
$second_ownerid=$form->value('Project.second_owner');
$isflag=false;
if($user['isadmin'] || $user['isgroupadmin'] || $second_ownerid==$user['id']){
$isflag=true;
}
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
		<h2><?php echo $form->value('Project.project_name');?></h2>
	</div>
    <div class="right back_btn"><?php 
    echo $html->link("返回","/projects/index");?></div>
    <?php
    	$is_audit=$form->value('Project.is_audit');
    	if(($user['isadmin'] || $user['isgroupadmin']) && $is_audit=="0"){
    		echo '<div class="right back_btn">';
    		
			
			echo "<a href='javascript:void(0)' onclick='return checkmove()'>确认移交</a>";
			
			echo '</div>';
		}else{
			echo '<div class="right enableaction">';
			echo "<a>移交</a>";
			echo '</div>';
		}
	?>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
    	<div class="details_info_content">
    		<?php echo $form -> create('companys', array('url' => '/projects/moveproject/'.$id,"id"=>"companys")); ?>
	    	<?php  echo $form->hidden('Project.id'); ?>
			<div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Project Name")?>：</div>
	                <div class="form_right_input left"><?php echo $form->value('Project.project_name');?></div>
	            </div>
	        </div>
	        <div class="details_item_line">
	             <div class="details_item">
	                <div class="form_left_title left"><?php __("Company Name")?>：</div>
	                <div class="form_right_input left">
	                <?php  echo $form->value('Project.company_name');?>
	                </div>
	            </div>
	        </div>
	        <div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Industry")?>：</div>
	                <div class="form_right_add left">
	                    <?php 
			            $industryidlist="";
			            if($pros_cvalues){
				            foreach($pros_cvalues as $pros_cvalue){
				            	if(!empty($pros_cvalue["cvid"])){
				            		$industryidlist.=$pros_cvalue["cvid"].',';
				            	}
				            }
			            }
			            ?>
			            <div id="pcvalueidlist" class="txthide"><?php echo $industryidlist?></div>
	                	<div id="taglist" class="added_item_list left"></div>
	                    <div class="add_item_btn left">
			                <div id="add_float_box" style="display:none;">
			                    <ul>
				                    <?php 
				                    $dan="'";
				                    foreach($industrys as $key=>$industry){
										echo "<li><label>";
										echo '<input type="checkbox" id="chbox'.$key.'" onclick="settxt(this,'.$dan.$industry.$dan.')" value="'.$key.'" />'.$industry;
										echo "</label></li>";
										echo "<span id='span".$key."' class='txthide'>".$industry."</span>";
									}?> 
								</ul>
			                </div>
						</div>
	                    <?php echo $form->text('Project.industryname',array('class'=>'txthide','readonly'=>'true','style'=>'width:500px'));?>
	                    
			            <?php echo $form->text('Project.industryid',array('class'=>'txthide'));?>
	                </div>
	            </div>
	        </div>
	          <div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Contact")?>：</div>
	                <div class="form_right_input left"><?php echo $form->value('Project.contact');?></div>
	            </div>
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Tel")?>：</div>
	                <div class="form_right_input left"><?php echo $form->value('Project.tel');?></div>
	            </div>
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Mail")?>：</div>
	                <div class="form_right_input left"><?php echo $form->value('Project.email');?></div>
	            </div>
	        </div>
	        <div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Regedit Time")?>：</div>
	                <div class="form_right_input form_date_picker left">
	                <?php echo $form->value('Project.reg_time');?>
	                </div>
	            </div>
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("Regedit Capital")?><span class="captype">(万)</span>：</div>
	                <div class="form_right_input left">
		                <?php echo $form->value('Project.cap_type')=="0"?"￥":"＄"?>
		                <?php echo $form->value("Project.capital");?>
	                </div>
	            </div>
	        </div>
	
	        <div class="txthide">
	        	<div class="details_item">
		        	<div class="form_left_title left"><?php __("In Phase")?>：</div>
		            <div class="form_right_input left">
		           
		            <?php 
			            $selectphase=$form->value("Project.phase");
			            echo $form->select('Project.phase',$phases,$selectphase,array("onchange"=>"selectregdecl(this)"),null);
			            echo $form->text('Project.txtphase',array('class'=>'txthide'));
		            ?>
		            <?php 
		        	echo $form->text('Project.selectphase',array('class'=>'txthide','value'=>$selectphase));
		        	?>
		        	
		            <?php 
		            	$selectregtype=$form->value("Project.reg_type");
			            echo $form->select('Project.reg_type',$reg_type,$selectregtype,
			            array("onchange"=>"selectregtypedecl(this)","id"=>"reg_type","class"=>"txthide"),null);
			            echo $form->text('Project.txtreg_type',array('class'=>'txthide'));
			        ?>
			        
			        <?php $select_phase=$form->value("Project.reg_decl_phase"); ?>
			        
		            <?php echo $form->select('Project.nreg_phase',$nreg_phase,$select_phase,
		            array("id"=>"nreg_phase","class"=>"txthide"),null);?>
		           
		        	
		        	<?php echo $form->select('Project.wreg_phase',$wreg_phase,$select_phase,
		        	array("id"=>"wreg_phase","class"=>"txthide"),null);?>
		        	
		        	
		        	<?php echo $form->select('Project.decl_phase',$decl_phase,$select_phase,
		        	array("id"=>"decl_phase","class"=>"txthide"),null);?>
		        	<?php 
		        	echo $form->text('Project.select_phase',array('class'=>'txthide1','value'=>$select_phase));
		        	?>
		        	</div>
	            </div>
	        </div>
	        <div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left"><?php __("In Phase")?>：</div>
	                  <div class="form_right_stage left">
	                   <table cellpadding="0" cellspacing="0">
	                        <tr>
	                        	<?php 
	                        	$pphase_cvalue=$objproject["phase_cvalue"]["value"];
	                        	$preg_cvalue=$objproject["reg_cvalue"]["value"];
	                        	$preg_decl_cvalue=$objproject["reg_decl_cvalue"]["value"];
	                        	$remark=$form->value("Project.remark");
	                        	
	                        	?>
	                        	
	                        	<?php 
	                    			$i=0;
	                    			$j=0;
	                    			$dan="'";
	                    			$phasescount=count($phases);
	                    			$selectedphase="";
	                    			$reg_phases=$preg_cvalue==$NRegistr?$nreg_phase:$wreg_phase;
	                    			$reg_phasescount=count($reg_phases);
//	                    			if($pphase_cvalue == $Incubate)
//	                    				array_pop($phases);
	                        		foreach($phases as $key=>$phase)
	                        		{
	                        			$selectedphase=$key==$selectphase?"selected":"";
	                        			$strphase=$phase;
	                        			if($pphase_cvalue==$Registr && $phase==$Registr && $preg_cvalue!=""){
	                        				$strphase=$preg_cvalue;
	                        				if($reg_phasescount%2!=0){
	                        					$phasescount=$phasescount+1;
	                        				}else{
	                        					$phasescount=$phasescount+2;
	                        				}
	                        				//$selectedphase="";
	                        			}
	                        			
	                        			if($pphase_cvalue==$Declare  && $phase==$Declare && !empty($preg_decl_cvalue)){
	                        				//$selectedphase="";
	                        			}
	                        			$tblclick="";
	                        			$selectcss="";
	                        			if($pphase_cvalue==$Registr && empty($preg_cvalue)){
	                        			
	                        			}
	                        			else if((empty($preg_cvalue) && empty($preg_decl_cvalue)) || ($phase==$Declare && empty($preg_decl_cvalue)))
	                        			{
	                        				if($isflag){
		                        				$tblclick=' onclick="setphase('.$dan.$key.$dan.')" ';
		                        				$selectcss="selectcss";
	                        				}
	                        			}
	                        			if($phase==$Declare && !empty($preg_cvalue))
	                        			{
	                        				if($isflag){
		                        				$tblclick=' onclick="setphase('.$dan.$key.$dan.')" ';
		                        				$selectcss="selectcss";
	                        				}
	                        			}
	                        			if($pphase_cvalue==$Declare){
	                    					$selectcss="";
	                    					$tblclick="";
	                    				}
	                        			if($i%2==0){
	                        				?>
	                        				<td class="per_node">
				                                <table id="tbl<?php echo $key?>" class="<?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
				                                    <tr>
				                                        <td colspan="3" class="stage_bubble"></td>
				                                    </tr>
				                                    <tr>
				                                        <td class="stage_node_line">
				                                        <?php if($i!=0){
				                                        	?>
				                                        		<hr color="#2989e2"/>
				                                        	<?php
				                                        }?>
				                                        </td>
				                                        <td><a></a></td>
				                                        <td class="stage_node_line">
				                                        	<?php 
				                                        	if($i!=($phasescount-1) || $pphase_cvalue==$Registr){?>
					                                        	<hr color="#2989e2"/>
					                                        <?php }?>
				                                        </td>
				                                    </tr>
				                                    <tr>
				                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_down strphase"><?php echo $strphase?></td>
				                                    </tr>
				                                </table>
				                            </td>
	                        				<?php
	                        			}
	                        			else{
	                        				?>
	                        				<td class="per_node">
				                                <table id="tbl<?php echo $key?>" class="<?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
				                                    <tr>
				                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_up strphase"><?php echo $strphase?></td>
				                                    </tr>
				                                    <tr>
				                                        <td class="stage_node_line"><hr color="#2989e2"/></td>
				                                        <td><a></a></td>
				                                        <td class="stage_node_line">
					                                        <?php 
					                                        if($i!=($phasescount-1) || $pphase_cvalue==$Registr){
					                                        	?>
					                                        	<hr color="#2989e2"/>
					                                        <?php }?>
				                                        </td>
				                                    </tr>
				                                    <tr>
				                                        <td colspan="3" class="stage_bubble"></td>
				                                    </tr>
				                                </table>
				                            </td>
	                        				<?php
	                        			}
	                        			if($pphase_cvalue==$Registr && $phase==$Registr && $preg_cvalue==""){
	                        				$reg_typecount=count($reg_type);
			                        		foreach($reg_type as $key=>$reg_phase)
			                        		{
			                        			$selectedphase="";
			                        			$selectcsss="";
				                        		$tblclick="";
				                        		if($isflag){
				                        			$selectcss="selectcss";
				                        			$tblclick=' onclick="setphase('.$dan.$key.$dan.')" ';
				                        		}
			                        			if($j%2==0){
			                        				?>
			                        				<td class="per_node">
						                                <table id="tbl<?php echo $key?>" class="subphase <?php echo $selectcsss?> <?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
						                                    <tr>
						                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_up strphase"><?php echo $reg_phase?></td>
						                                    </tr>
						                                    <tr>
						                                        <td class="stage_node_line"><hr color="#2989e2"/></td>
						                                        <td><a></a></td>
						                                        <td class="stage_node_line">
						                                        	<?php if($j!=($reg_typecount-1)){?>
						                                        	<hr color="#2989e2"/>
						                                        	<?php }?>
						                                        </td>
						                                    </tr>
						                                    <tr>
						                                        <td colspan="3" class="stage_bubble"></td>
						                                    </tr>
						                                </table>
						                            </td>
			                        				<?php
			                        			}else{
			                        				?>
			                        				<td class="per_node">
						                                <table id="tbl<?php echo $key?>" class="subphase <?php echo $selectcsss?> <?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
						                                    <tr>
						                                        <td colspan="3" class="stage_bubble"></td>
						                                    </tr>
						                                    <tr>
						                                        <td class="stage_node_line">
						                                        	<hr color="#2989e2"/>
						                                        </td>
						                                        <td><a></a></td>
						                                        <td class="stage_node_line">
						                                        	<?php if($j!=($reg_typecount-1)){?>
						                                        	<hr color="#2989e2"/>
						                                        	<?php }?>
						                                        </td>
						                                    </tr>
						                                    <tr>
						                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_down strphase"><?php echo $reg_phase?></td>
						                                    </tr>
						                                </table>
						                            </td>
			                        				<?php
			                        			}
			                        			$j++;
			                        		}
			                        	}
	    
	                        			if($pphase_cvalue==$Registr && $phase==$Registr && $preg_cvalue!=""){
	                        				$i++;
	                        				if($reg_phasescount%2==0){
	                        					$i++;
	                        				}
			                        		$selectedphase="";
			                        		$reg_phase=array();
			                        		if($preg_cvalue==$NRegistr){
			                        			
			                        		}
			                        		$reg_phasescount=count($reg_phases);
			                        		foreach($reg_phases as $key=>$reg_phase)
			                        		{
			                        			$selectedphase=$key==$select_phase?"selected":"";
			                        			
			                        			$titleremark="";
			                        			$strremark="";
			                        			if(stripos($reg_phase,"前置")>-1 && $remark){
				                        			$strremark="...";
				                        			$titleremark="title='".$remark."'";
				                        		}
				                        		$selectcss="";
				                        		$tblclick="";
				                        		if($isflag){
				                        			$selectcss="selectcss";
				                        			$tblclick=' onclick="setphase('.$dan.$key.$dan.',1)" ';
				                        		}
			                        			if($j%2==0){
			                        				?>
			                        				<td class="per_node">
						                                <table id="tbl<?php echo $key?>" class="subphase <?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
						                                    <tr>
						                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_up strphase" <?php echo $titleremark?>><?php echo $reg_phase.$strremark?></td>
						                                    </tr>
						                                    <tr>
						                                        <td class="stage_node_line"><hr color="#2989e2"/></td>
						                                        <td><a></a></td>
						                                        <td class="stage_node_line">
						                                        	<?php if($j!=($reg_phasescount-1)){?>
						                                        	<hr color="#2989e2"/>
						                                        	<?php }?>
						                                        </td>
						                                    </tr>
						                                    <tr>
						                                        <td colspan="3" class="stage_bubble"></td>
						                                    </tr>
						                                </table>
						                            </td>
			                        				<?php
			                        			}else{
			                        				?>
			                        				<td class="per_node">
						                                <table id="tbl<?php echo $key?>" class="subphase <?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
						                                    <tr>
						                                        <td colspan="3" class="stage_bubble"></td>
						                                    </tr>
						                                    <tr>
						                                        <td class="stage_node_line">
						                                        	<hr color="#2989e2"/>
						                                        </td>
						                                        <td><a></a></td>
						                                        <td class="stage_node_line">
						                                        	<?php if($j!=($reg_phasescount-1)){?>
						                                        	<hr color="#2989e2"/>
						                                        	<?php }?>
						                                        </td>
						                                    </tr>
						                                    <tr>
						                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_down strphase" <?php echo $titleremark?> ><?php echo $reg_phase.$strremark?></td>
						                                    </tr>
						                                </table>
						                            </td>
			                        				<?php
			                        			}
			                        			$j++;
			                        		}
			                        	}
	                        			$i++;
	                        		}
	                        	?>
	                        	<?php if($pphase_cvalue==$Declare){
	                        		$j=0;
	                        		$selectedphase="";
	                        		$decl_phasecount=count($decl_phase);
	                        		foreach($decl_phase as $key=>$decl_phases)
	                        		{
	                        			$selectedphase=$key==$select_phase?"selected":"";
	                        			$selectcss="";
		                        		$tblclick="";
		                        		if($isflag){
		                        			$selectcss="selectcss";
		                        			$tblclick=' onclick="setphase('.$dan.$key.$dan.',1)" ';
		                        		}
	                        			if($j%2!=0){
	                        				?>
	                        				<td class="per_node">
				                                <table id="tbl<?php echo $key?>" class="subphase <?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
				                                    <tr>
				                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_up strphase"><?php echo $decl_phases?></td>
				                                    </tr>
				                                    <tr>
				                                        <td class="stage_node_line"><hr color="#2989e2"/></td>
				                                        <td><a></a></td>
				                                        <td class="stage_node_line">
				                                        	<?php if($j!=($decl_phasecount-1)){?>
				                                        	<hr color="#2989e2"/>
				                                        	<?php }?>
				                                        </td>
				                                    </tr>
				                                    <tr>
				                                        <td colspan="3" class="stage_bubble"></td>
				                                    </tr>
				                                </table>
				                            </td>
	                        				<?php
	                        			}else{
	                        				?>
	                        				<td class="per_node">
				                                <table id="tbl<?php echo $key?>" class="subphase <?php echo $selectedphase?>" cellpadding="0" cellspacing="0">
				                                    <tr>
				                                        <td colspan="3" class="stage_bubble"></td>
				                                    </tr>
				                                    <tr>
				                                        <td class="stage_node_line">
				                                        	<hr color="#2989e2"/>
				                                        </td>
				                                        <td><a></a></td>
				                                        <td class="stage_node_line">
				                                        	<?php if($j!=($decl_phasecount-1)){?>
				                                        	<hr color="#2989e2"/>
				                                        	<?php }?>
				                                        </td>
				                                    </tr>
				                                    <tr>
				                                        <td colspan="3" <?php echo $tblclick?> class="<?php echo $selectcss?> stage_bubble stage_bubble_down strphase"><?php echo $decl_phases?></td>
				                                    </tr>
				                                </table>
				                            </td>
	                        				<?php
	                        			}
	                        			$j++;
	                        		}
	                        	}?>
	                        </tr>
	                    </table>
	                </div>
	           </div>
	        </div>
	        <div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left"></div>
	                <div class="left pharas_color_details">
						<ul>
							<li>
								<div class="color_block_n left"></div>
								<div class="color_block_intro left">项目阶段结点</div>
								<div class="clear"></div>
							</li>
							<li>
								<div class="color_block_s left"></div>
								<div class="color_block_intro left">项目阶段子阶段结点</div>
								<div class="clear"></div>
							</li>
							<li>
								<div class="color_block_t left"></div>
								<div class="color_block_intro left">当前项目阶段结点</div>
								<div class="clear"></div>
							</li>
						</ul>
					</div>
	            </div>
	        </div>
	        <?php if($isflag){?>
		    <div class="details_item_line">
		    	<div class="details_item" id="examineremark" style="display:none">
		        	<div class="form_left_title left">前置审批备注：</div>
		        	<div class="form_right_ajax_input left">
		        		<?php echo $form->textarea('Project.remark',array("onblur"=>"editremark(this)",'style'=>'width:200px;height:50px'));?>
		        		<div id="setremark" style="display:none"><?php echo $form->value('Project.remark')?></div>
		        	</div>
		        </div>
		    </div>
		    <?php }?>
		    <div class="details_item_line">
	            <div class="details_item">
	                <div class="form_left_title left">选择电子材料：</div>
	                <div class="form_right_input left">
	                	<?php ?>
	                	<div class="file_category_list">
			        		<div id="filelist0" class="file_lists">
			        			<ul class="file_attach">
				                	<?php
				                	if($attachments){
					                	$dan="'";
					                	$second_ownerid=$form->value('Company.second_owner');
					                	$isflag=$action->checkPermissions($user,$id);
					                	$i=0;
					                	foreach($attachments as $attachment) {
											echo "<li>";
											echo '<span>'.$form->checkbox('fileidlist.'.$i,array('value'=>$attachment['id'])).'</span>';
											echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
											echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
											echo "</li>";
											$i++;
										}
									}else{
										echo "暂无文件";
									}
				                	?>
				                </ul>
			                </div>
			            </div>
			        </div>
			    </div>
		    </div>
		</form>
		</div>
    </div>
</div>
<?php echo $this->element('constant') ?>
<?php echo $javascript->link('project.js');?>
<?php echo $this->element('actionconfirm',array("title"=>"阶段设置提示","message"=>"你确定吗？")) ?>
<script>
	var webpath=$("#getpath").attr('href');
	function editremark(obj)
	{
		$(obj).parent('.form_right_ajax_input').addClass("form_right_e_input");
		$(obj).parent('.form_right_ajax_input').removeClass("form_right_ajax_input");
		var pid=$("#ProjectId").val();
		var remark=$("#ProjectRemark").val();
		var setremark=$("#setremark").html();
		if(remark!="" && remark!=setremark){
		var urlpath=webpath+'projects/editremark/'+pid+'/'+encodeURIComponent(remark);
			$.ajax({     	   
			        url: urlpath, 
			        success:function(data){
			        	$("#tbl"+aid).find(".strphase").attr("title",data);
			        	$("#setremark").html(data.trim());
			        	showmessage("前置审批备注保存成功");
			        }      
			     });
		}
	}
	function checkmove() {
		$("#ui-dialog-title-1").html("移交项目提示");
		$(".confirm_model").dialog( "open" );
		$("#ok").click(function() {
			$(".confirm_model").dialog( "close" );
			$("#companys").submit();
		});
		return false;
	}
	$(document).ready(function() {
		 $("#ProjectEmail").keyup(function() {  
		     	var mail=this.value;
		     	checkuserbymail(webpath,mail,"#projectemailmessage");
		    });
	});
</script>